//package com.java46.carera.admin.realm;
//
//import com.java46.carera.admin.service.AdminService;
//import com.java46.carera.base.entity.Admin;
//import com.java46.carera.base.exception.BusinessException;
//import org.apache.shiro.authc.*;
//import org.apache.shiro.authz.AuthorizationInfo;
//import org.apache.shiro.realm.AuthorizingRealm;
//import org.apache.shiro.subject.PrincipalCollection;
//import org.springframework.beans.factory.annotation.Autowired;
//
///**
// * @ClassName adminRealm
// * @Description TODO
// * @Author Administrator
// * @Date 2018/8/21 0021 9:55
// * @Vcrsion 1.0
// **/
//public class AdminRealm extends AuthorizingRealm {
//
//    @Autowired
//    private AdminService adminService;
//
//    @Override
//    public String getName() {
//        return "customRealm";
//    }
//
//    /**
//     * 认证
//     */
//    @Override
//    protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken token) throws AuthenticationException {
//        // 获取用户名称
//        String username = (String) token.getPrincipal();
//        Admin admin = adminService.findByAdmUser(username);
//        if (admin == null) {
//            // 用户名不存在抛出异常
//            System.out.println("认证：当前登录的管理员不存在");
//            throw new BusinessException("认证：当前登录的管理员不存在");
//        }
//        String pwd = admin.getAdmpwd();
//        return new SimpleAuthenticationInfo(admin, pwd, getName());
//    }
//
//    /**
//     * 授权
//     */
//
//    @Override
//    protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principalCollection) {
//        return null;
//    }
//}